package com.onehash.onebilling.gui;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;



public class SplashWindow extends Window {
    private JLabel imageLabel;
    private JLabel processLabel;

    public SplashWindow(Frame parent) {
        super(parent);
        /* instantiating UI components */
        imageLabel = new JLabel();
        processLabel = new JLabel();
        /* initiazing UI components */
        imageLabel.setBounds(new Rectangle(0, 0, 600, 300));
        processLabel.setBounds(new Rectangle(5, 275, 300, 30));
        add(processLabel, null);
        add(imageLabel, null);
        setSize(600, 300);
        this.centerFrame();
    }

    //Center the splash screen
    private void centerFrame(){
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = this.getSize();
        if (frameSize.height > screenSize.height)
          frameSize.height = screenSize.height;
        if (frameSize.width > screenSize.width)
          frameSize.width = screenSize.width;
        this.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    }

    public void setIcon(Icon icon){
        imageLabel.setIcon(icon);
    }

    public void setText(String text) {
        processLabel.setText(text);
    }
}
